from openai import OpenAI


# Please install OpenAI SDK first: `pip3 install openai`


# deepseek大模型
DeepSeek_API_Key = 'sk-3fb97ba2ce844cf7a6ac461a51e34a7c'


while True:
    print('欢迎来到deepseek大模型')

    print('==============================')

    Question = input('请输入您的问题：')

    print('保存问题中')

    Question_Newline = '\n' + '\n' + '\n'

    with open('deepseek.txt', 'a', encoding='utf-8') as f:
        f.write('问题：' + Question + Question_Newline)

    print('正在思考：1')

    client = OpenAI(api_key=DeepSeek_API_Key, base_url="https://api.deepseek.com")

    print('正在思考：2')

    response = client.chat.completions.create(
        #
        # model="deepseek-chat",
        #
        model='deepseek-reasoner',
        messages=[
            {"role": "system", "content": "You are a helpful assistant"},
            {"role": "user", "content": Question},
        ],
        stream=False
    )

    print(response.choices[0].message.content)

    content = response.choices[0].message.content

    Newline = '\n' + '\n' + '\n' + '\n' + '\n' + '\n' + '\n'

    with open('deepseek.txt', 'a', encoding='utf-8') as f:
        f.write(content + Newline)

    print('==============================')






#
#
#